//package cn.iocoder.yudao.module.engine.controller.app.session;
//
//import cn.iocoder.yudao.framework.common.pojo.CommonResult;
//import cn.iocoder.yudao.framework.common.pojo.PageResult;
//import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
//import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
//import cn.iocoder.yudao.module.engine.controller.app.session.vo.AppSessionPageReqVO;
//import cn.iocoder.yudao.module.engine.controller.app.session.vo.AppSessionRespVO;
//import cn.iocoder.yudao.module.engine.controller.app.session.vo.AppSessionSaveReqVO;
//import cn.iocoder.yudao.module.engine.controller.app.session.vo.AppSessionSaveResVO;
//import cn.iocoder.yudao.module.resource.api.ICosplayApi;
//import cn.iocoder.yudao.module.resource.api.ISessionApi;
//import cn.iocoder.yudao.module.resource.api.model.session.SessionDTO;
//import cn.iocoder.yudao.module.resource.api.model.session.SessionPageReqDTO;
//import io.swagger.v3.oas.annotations.Operation;
//import io.swagger.v3.oas.annotations.Parameter;
//import io.swagger.v3.oas.annotations.tags.Tag;
//import jakarta.annotation.Resource;
//import jakarta.validation.Valid;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.*;
//
//import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
//import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
//
//@Tag(name = "用户 APP - 会话")
//@RestController
//@RequestMapping("/lm/session")
//@Validated
//public class AppSessionController {
//
//    @Resource
//    private ISessionApi sessionApi;
//    @Resource
//    private ICosplayApi cosplayApi;
//
//    @PostMapping("/create")
//    @Operation(summary = "创建会话")
//    @PreAuthenticated
//    public CommonResult<AppSessionSaveResVO> createSession(@Valid @RequestBody AppSessionSaveReqVO createReqVO) {
//        final Long loginUserId = getLoginUserId();
//        final Integer roleId = createReqVO.getRoleId();
//        final Integer storyId = createReqVO.getStoryId();
//
//        cosplayApi.validateCosplayExists(roleId);
//
//        final Long sessionId =  sessionApi.getSessionByRoleIdWithLock(loginUserId, Long.valueOf(roleId), storyId);
//
//        final AppSessionSaveResVO resVO = new AppSessionSaveResVO();
//        resVO.setSessionId(sessionId);
//        return success(resVO);
//    }
//
//    @DeleteMapping("/delete")
//    @Operation(summary = "删除会话")
//    @Parameter(name = "id", description = "编号", required = true)
//    @PreAuthenticated
//    public CommonResult<Boolean> deleteSession(@RequestParam("id") Long id) {
//        final Long loginUserId = getLoginUserId();
//        sessionApi.deleteSessionByUserId(loginUserId, id);
//        return success(true);
//    }
//
//    @GetMapping("/get")
//    @Operation(summary = "获得会话")
//    @Parameter(name = "id", description = "编号", required = true, example = "1024")
//    @PreAuthenticated
//    public CommonResult<AppSessionRespVO> getSession(@RequestParam("id") Long id) {
//        final Long loginUserId = getLoginUserId();
//        SessionDTO session = sessionApi.getSessionByUserId(loginUserId, id);
//        return success(BeanUtils.toBean(session, AppSessionRespVO.class));
//    }
//
//    @GetMapping("/page")
//    @Operation(summary = "获得会话分页")
//    @PreAuthenticated
//    public CommonResult<PageResult<AppSessionRespVO>> getSessionPage(@Valid AppSessionPageReqVO pageReqVO) {
//        final Long loginUserId = getLoginUserId();
//        PageResult<SessionDTO> pageResult = sessionApi.selectPageByUserId(loginUserId, BeanUtils.toBean(pageReqVO, SessionPageReqDTO.class));
//        return success(BeanUtils.toBean(pageResult, AppSessionRespVO.class));
//    }
//
//}